/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.wpi.first.wpilibj.defaultCode;

import edu.wpi.first.wpilibj.Joystick;

/**
 *
 * @author Mark
 */
public class TargetTuner
{
    public static int TARGET = 180;

    public static void tuneTarget(Joystick joystick)
    {
       int currValue = TARGET;

       System.out.println("\nEntering Target maintenance for ");

       System.out.println("To exit this mode, press the trigger.");


       System.out.println("Current value is: " + currValue);
       System.out.println("To increase, press forward. To decrease, pull back on the joystick.");
       System.out.println("To select the new value, press the trigger.");

       double yValue;

       while(!joystick.getRawButton(1))
       {
           yValue = joystick.getY();

           if(Math.abs(yValue) >=.2)
           {
               if(yValue <= .2)
               {
                   currValue = currValue + 15;
               }
               else
               {
                   currValue = currValue - 15;
               }

               System.out.println(currValue);

               try
               {
                Thread.sleep(500);
               }
               catch (InterruptedException ex)
                {
                    ex.printStackTrace();
                }
           }
       }

       TARGET = currValue;

       System.out.println("Target set to: " + TARGET);
    }
}
